const { DataTypes } = require('sequelize');
const sequelize = require('@shared/utils/database');

const Category = sequelize.define('Category', {
  id: {
    type: DataTypes.BIGINT,
    primaryKey: true,
    autoIncrement: true,
    comment: '分类ID'
  },
  parent_id: {
    type: DataTypes.BIGINT,
    allowNull: false,
    defaultValue: 0,
    comment: '父分类ID，0表示一级分类'
  },
  name: {
    type: DataTypes.STRING(32),
    allowNull: false,
    comment: '分类名称'
  },
  sort: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0,
    comment: '排序'
  },
  status: {
    type: DataTypes.TINYINT,
    allowNull: false,
    defaultValue: 1,
    comment: '状态：0-禁用 1-正常'
  }
}, {
  tableName: 'category',
  timestamps: true,
  createdAt: 'create_time',
  updatedAt: 'update_time'
});

module.exports = Category; 